package com.stars.empoly.activity

import android.graphics.Color
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.githang.statusbar.StatusBarCompat
import com.stars.empoly.adapter.FragAdapter
import com.stars.empoly.base.MBActivity
import com.stars.empoly.databinding.ActivityGuideBinding
import com.stars.empoly.fragment.OneFragment
import com.stars.empoly.fragment.ThreeFragment
import com.stars.empoly.fragment.TwoFragment
import com.stars.empoly.vmodel.GuideVModel

/**
 * 引导页
 *on 2021/6/21
 */
class GuidActivity: MBActivity<GuideVModel, ActivityGuideBinding>() {

    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)
        StatusBarCompat.setStatusBarColor(this, Color.parseColor("#00ffffff"))

        initViewPager()
    }


    fun initViewPager(){

        var list = java.util.ArrayList<Fragment>()
        var one = OneFragment()
        var two = TwoFragment()
        var three = ThreeFragment()
        list.add(one)
        list.add(two)
        list.add(three)
        val adapter = FragAdapter(supportFragmentManager, list)//childFragmentManager
        binding.viewpager.adapter = adapter
        binding.viewpager.offscreenPageLimit = list.size

        binding.indicator.setViewPager(binding.viewpager)

        binding.viewpager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
            override fun onPageScrolled(
                    position: Int,
                    positionOffset: Float,
                    positionOffsetPixels: Int
            ) {

            }

            override fun onPageSelected(position: Int) {
                //vm.number.value = (position + 1).toString()
            }

            override fun onPageScrollStateChanged(state: Int) {

            }
        })




    }

    override fun title(): String? {
        return null
    }


    override fun transluent(): Boolean {
        return true
    }


    override fun vmClass(): Class<GuideVModel> {
        return GuideVModel::class.java
    }
    override fun binding(): ActivityGuideBinding {
        return ActivityGuideBinding.inflate(layoutInflater)
    }
}
